package com.service.consumer.controller;

import com.service.consumer.feign.RemoteProviderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;


/**
 * @author 24466
 * @date 2024/9/22 15:30
 */
@RestController
public class ConsumerController {

    @Autowired
    private RestTemplate restTemplate;

    @Autowired
    private RemoteProviderService remoteProviderService;

    @RequestMapping(value = "/consumer/{str}", method = RequestMethod.GET)
    public String echo(@PathVariable("str") String str) {
        // return "consumer: " + restTemplate.getForObject("http://microservice-provider/provider/" + str, String.class);
        String echo = remoteProviderService.echo(str);

        return echo;
    }
}

